package Day14_ArrayList.考试;

import java.util.ArrayList;

public class MainApp {
    public static void main(String[] args) {
        //创建集合
        ArrayList<Student> list = new ArrayList<>();
        //创建对象
        Student s1 = new Student("黄渤","it001",1.72);
        Student s2 = new Student("孙红雷","it002",1.78);
        Student s3 = new Student("章子怡","it003",1.64);
        Student s4 = new Student("杨颖","it004",1.68);
        //添加到集合
        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        //遍历
        for (int i = 0; i < list.size(); i++) {
            Student s = list.get(i);
            System.out.println(s.getName() + "," + s.getNum() + "," + s.getTall());
        }
        //获取第三个对象
        System.out.println(list.get(2).getName() + "," + list.get(2).getNum() + "," + list.get(2).getTall());
        //移除第四个对象
        list.remove(3);
        //替换
        Student s5 = new Student("撒贝宁","it005",1.74);
        list.set(0,s5);
        //打印长度
        System.out.println(list.size());


    }
}
